﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 第三次课堂作业
{
    class Rectangle : Shape
    {
        private double width;
        private double height;

        public Rectangle(double width,double height)
        {
            this.width = width;
            this.height = height;
            if(isLegal())
            {
                Console.WriteLine("This is a Rectangle. The area is " + Area);
            }
            else
            {
                Console.WriteLine("The input is not legal. Make another Instance.");
            }
        }

        public override double Area
        {
            get
            {
                return width * height;
            }
        }

        public override bool isLegal()
        {
            if (width <= 0 || height <= 0)
                return false;
            return true;
        }
    }
}
